class FVue {
    constructor(options) {
        this.$data = options.data //保存data数据
        this.observe(this.$data)
    }
    observe(value) {
        if (!value || typeof value !== "object") {
            return;
        }
        Object.keys(value).forEach(key => {
            this.defineReactive(value, key, value[key])
        })
    }
    defineReactive(obj, key, val) {
        this.observe(val)
        Object.defineProperty(obj, key, {
            enumerable: true,
            configurable: true,
            get() {
                return val
            },
            set(newValue) {
                if (newValue == val) {
                    return;
                }
                console.log("数据发生变化")
                val = newValue
            }
        })
    }
}